﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using SolutionSorter.Core.Test.Properties;

namespace SolutionSorter.Core.Test
{
    [TestFixture]
    public class ContentSorterTest
    {
        [Test]
        public void CanExtractPreProjectContent()
        {
            string expected = "\r\nMicrosoft Visual Studio Solution File, Format Version 10.00\r\n# Visual Studio 2008\r\n";
            var sorter = new ContentSorter(new DefaultConfiguration());
            Assert.AreEqual(expected, sorter.ExtractPreProjectContent(Resources.SolutionContentUnsorted));
        }

        [Test]
        public void CanExtractPostProjectContent()
        {
            string expected = Resources.PostProjectSolutionContent;
            var sorter = new ContentSorter(new DefaultConfiguration());
            Assert.AreEqual(expected, sorter.ExtractPostProjectContent(Resources.SolutionContentUnsorted));
        }

        [Test]
        public void CanExtractProjectContent()
        {
            string expected = Resources.ProjectSolutionContent;
            var sorter = new ContentSorter(new DefaultConfiguration());
            Assert.AreEqual(expected, sorter.ExtractProjectContent(Resources.SolutionContentUnsorted));
        }

        [Test]
        public void CanSortProjectContent()
        {
            string expected = Resources.SortedProjectSolutionContent;
            var sorter = new ContentSorter(new DefaultConfiguration());
            var projectContent = sorter.ExtractProjectContent(Resources.SolutionContentUnsorted);
			var nestedProjectsContent = sorter.ExtractNestedProjectsContent(Resources.SolutionContentUnsorted);
			var solutionItems = sorter.ParseProjectContent(sorter.ExtractProjectContent(Resources.SolutionContentUnsorted));
			Assert.AreEqual(expected, sorter.SortProjectContent(nestedProjectsContent, solutionItems));
        }

        [Test]
        public void CanSortTreeProjectContent()
        {
            string expected = Resources.TreeSolutionContentSorted;
            var sorter = new ContentSorter(new DefaultConfiguration());
            var sortedContent = sorter.SortContent(Resources.TreeSolutionContentUnsorted);
            Assert.AreEqual(expected, sortedContent);
        }
    }
}
